<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	protected function _initSession()
	{
		Zend_Session::start();
	}
	protected function _initDb()
	{
		$optionResources 	= $this->getOption('resources');
		
		$dbOption 			= $optionResources['db'];
		
		$configMail 		= $optionResources['mail'];
		
		$dbOption['params']['username'] = 'root';
		$dbOption['params']['password'] = '123';
		$dbOption['params']['dbname'] 	= 'cmath';
		
		$adapter 	= $dbOption['adapter'];
		$config 	= $dbOption['params'];
		$db 		= Zend_Db::factory($adapter,$config);
		$db->setFetchMode(Zend_Db::FETCH_ASSOC);
		$db->query("SET NAMES 'utf8'");
		$db->query("SET CHARACTER SET 'utf8'");
		
		Zend_Registry::set('connectDb',$db);
		
		Zend_Registry::set('configMail',$configMail);
		
		Zend_Db_Table::setDefaultAdapter($db);
		
		return $db;
	}
	protected function _initFrontcontroller()
	{
		$front = Zend_Controller_Front::getInstance();
		$front->addModuleDirectory(APP_PATH . '/modules');
		$front->setDefaultModule('default');
		$front->registerPlugin(new Myh_Plugin_Permission());
		$front->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(array(
				'module'     => 'error',
				'controller' => 'error',
				'action'     => 'error'
			)));
		return $front;
	}
}